# 学员信息在线管理
#导入操作数据的类
from manager import Manager

#主函数
def main():
	#实例化对象 
	opt = Manager()

	while True:
		# 输出初始界面
		print("="*12,"学员管理系统","="*14)
		print("{0:1} {1:13} {2:15}".format(" ","1. 查看学员信息","2. 添加学员信息"))
		print("{0:1} {1:13} {2:15}".format(" ","3. 删除学员信息","4. 退出系统"))
		print("="*40)
		key = input("请输入对应的选择：")
		
		# 根据键盘值，判断并执行对应的操作
		if key == "1":
			print("="*12,"学员信息浏览","="*14)
			
			stulist = opt.showStu()

			print("|{0:<1}| {1:<10}| {2:<5}| {3:<20}|".format("sid","name","age","classid"))
			print("-"*40)
			for row in stulist:
				sid =row[0]
				name = row[1]
				age = row[2]
				classid = row[3]
				print("|{0:<3}| {1:<10}| {2:<5}| {3:<20}|".format(sid,name,age,classid))
				#print("| {0:<10}| {1:<5}| {2:<10}|".format(name,age,classid))

			input("按回车键继续：")
		elif key == "2":
			print("="*12,"学员信息添加","="*14)

			name = input("请输入要添加的姓名：")
			age = input("请输入要添加的年龄：")
			classid = input("请输入要添加的班级号：")
			
			opt.addStu(name,age,classid)

			input("按回车键继续：")
		elif key == "3":
			print("="*12,"学员信息删除","="*14)

			opt.showStu()

			name = input("请输入你要删除的名称：")
			opt.delStu(name)

			input("按回车键继续：")
		elif key == "4":
			print("="*12,"再见","="*14)
			break
		else:
			print("======== 无效的键盘输入！ ==========")



# 判断当前是否是主程序，若是就执行主程序。
if __name__ == "__main__":
    main()
